package com.wangzhixuan.service;

import com.wangzhixuan.db.bean.Customer;
import com.wangzhixuan.db.dao.CustomerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class CustomerService {

    @Autowired
    private CustomerDao customerDao;

    /**
     * Add customer
     *
     * @param customer
     * @return Integer new created customer Id
     */
    public int addCustomer(Customer customer){
        return customerDao.addCustomer(customer);
    }

    /**
     * update customer
     *
     * @param customer
     * @return
     */
    public int updateCustomer(Customer customer){
        return customerDao.updateCustomer(customer);
    }

    /**
     * Get customer by openId
     *
     * @param openId
     * @return
     */
    public Customer getCustomerByOpenId(String openId){
        return customerDao.getCustomerByOpenId(openId);
    }

    /**
     * Get customer by customerId
     *
     * @param customerId
     * @return
     */
    public Customer getCustomerById(long customerId) {
        Customer customer = customerDao.getCustomerById(customerId);
        return customer;
    }

}
